using System.IO;
using UnityEditor;
using UnityEngine;

public class CopyEditor
{
    private const string ScriptAssembliesAotDir = "HybridCLRData/AssembliesPostIl2CppStrip/";
    private const string ScriptAssembliesDir = "HybridCLRData/HotUpdateDlls/";
    private const string CodeTargetDir = "Assets/AssetsPackage/Dll/Code/";
    private const string MetadataCodeTargetDir = "Assets/AssetsPackage/Dll/MetaDataCode/";
    private const string HotfixDll = "Unity.Hotfix.dll";

    //[MenuItem("Tools/CopyHotDll")]
    static void CopyHotDll()
    {
        File.Copy(Path.Combine(ScriptAssembliesDir + EditorUserBuildSettings.activeBuildTarget, HotfixDll),
            Path.Combine(CodeTargetDir, HotfixDll + ".bytes"), true);
        Debug.Log($"复制Hotfix.dll到{CodeTargetDir}完成");
    }

    //[MenuItem("Tools/CopyAotHotDll")]
    static void CopyAotHotDll()
    {
        for (int i = 0; i < GameConfigApp.AotDllNameList.Count; i++)
        {
            File.Copy(
                Path.Combine(ScriptAssembliesAotDir + EditorUserBuildSettings.activeBuildTarget,
                    GameConfigApp.AotDllNameList[i]),
                Path.Combine(MetadataCodeTargetDir, GameConfigApp.AotDllNameList[i] + ".bytes"), true);
        }
        Debug.Log($"复制补充元数据的dll到{MetadataCodeTargetDir}完成");
    }

    [MenuItem("Tools/CopyAllHotDll")]
    static void CopyAllHotDll()
    {
        CopyHotDll();
        CopyAotHotDll();
        AssetDatabase.Refresh();
    }
}